use aspect_codec::inst_struct_codec;
use aspect_codec::{inst_semimanual_codec, prelude::*};

use super::crypto;
use super::device;

/// Pledge from a server of sponsorship of a device.
#[derive(Clone, Debug)]
pub struct Attestation {
    sponsor_domain: String,
    sig: crypto::Signature,
}

inst_struct_codec! {
    Attestation {
        sponsor_domain: String,
        sig: crypto::Signature
    }
}

/// Provided to a server to sign an device attestation.
#[derive(Clone, Debug)]
pub struct AttestationRequest {
    /// Identity we're signing, which can be known before the initial record is created.
    ident: device::DeviceIdent,

    /// Short username we're using.  The server shouldn't sponsor two different
    /// identities with the same short name, although it wouldn't be strictly
    /// wrong to.
    short_name: String,
}

inst_struct_codec! {
    AttestationRequest {
        ident: device::DeviceIdent,
        short_name: String
    }
}
